home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / blf082b / blouf.h < prev    next >
C/C++ Source or Header  |  1993-12-11  |  9KB  |  282 lines

  1. /*
  2.  *    BloufGate -- A Free Fido / Usenet Gateway Program
  3.  *    =========
  4.  *    
  5.  *    Header File TO EDIT FOR CONFIGURATION
  6.  *    (use 4 spaces a TAB for nicer layout)
  7.  *
  8.  *    Public Domain: may be copied and sold freely
  9.  *
  10.  *    Originally written by Vincent Pomey and Franck Arnaud
  11.  *    With contributions from Thierry Bousch
  12.  */
  13. /* ------------------------------------ Include Files */
  14.  
  15. #include    <stdio.h>
  16. #include    <string.h>
  17. #include    <stdarg.h>
  18. #include    <stdlib.h>
  19. #include    <time.h>
  20. #include    <ctype.h>   
  21. #include    <errno.h>
  22.  
  23. #include    "portab.h"    /* WORD, LONG, etc declarations */
  24.  
  25. /* ------------------------------------ Program Configuration */
  26.  
  27. /*#define BATCHSMTP                  *//* output batch smtp */
  28. #define    DEBUG                        /* Enable debug code */
  29. #define    Version         "0.8.2"        /* Version number */
  30. #define    ProgName           "BloufGate"    /* program name */
  31. #define    ProdCode           0xE8        /* FTSC registered product code for BloufGate */
  32. #define USE_RFCID                      /* use the proposed RFCID kludge */
  33. #define USE_CHRS                    /* use CHRS kludge to describe ISO Latin-1 usenet defaults charset */
  34. #define KILL_DUPES                    /* use dupe checker */
  35. #define MAXCROSS         3             /* Max number of crosspost to fido groups */
  36.  
  37. /* System dep. defintions:
  38.     DEFAULT_CONFIG    default configuration file
  39.     BLF_DSEPAR        directory separator
  40.     BLF_BUFSIZE        news unbacther buffer */
  41.  
  42. #ifdef UNIX     /* Unix: tested with GCC 2.2, GNU Libs, under Linux */
  43.  
  44. #define DEFAULT_CONFIG  "/etc/blouf.cfg"
  45. #define BLF_DSEPAR      '/'
  46. #define BLF_BUFSIZE     200000
  47. #define stricmp strcasecmp
  48. #define strnicmp strncasecmp
  49.  
  50. #elif ST_GCC /* Atari ST: GCC, MiNT */
  51.  
  52. #define DEFAULT_CONFIG  "/etc/blouf.cfg"
  53. #define BLF_DSEPAR      '/'
  54. #define BLF_BUFSIZE     200000
  55. #include <unistd.h>
  56.  
  57. #elif ST_PUREC /* Atari ST: Turbo/Pure C */
  58.  
  59. #define DEFAULT_CONFIG     "blouf.cfg"    /* default config */
  60. #define BLF_DSEPAR         '\\'         /* Directory separator */
  61. #define BLF_BUFSIZE        100000        /* news unbatch buffer */
  62. #include <tos.h>
  63. #include <ext.h>  /* getcwd etc */
  64.  
  65. #elif ST_LATTICE /* Atari ST,Tos: Lattice C 5 */
  66.  
  67. #define DEFAULT_CONFIG     "blouf.cfg"    /* default config */
  68. #define BLF_DSEPAR         '\\'         /* Directory separator */
  69. #define BLF_BUFSIZE        100000        /* news unbatch buffer */
  70. #include <osbind.h> /* tos, pour Fsfirst/Fsnext/Fsetdta, FGATE */
  71. #undef min
  72. #undef max /* disable built-in funcs (int only) */
  73.  
  74. #elif WIN32 /* Windows NT, tested with 0393BETA SDK/MCVC++ 32 */
  75.  
  76. #define DEFAULT_CONFIG     "blouf.cfg"    /* default config */
  77. #define BLF_DSEPAR         '\\'         /* Directory separator */
  78. #define BLF_BUFSIZE        100000        /* buffer */
  79. #include <io.h>
  80.  
  81. #elif MSDOS_MSC /* DOS with MicroSoft C 7.00, 8.00 (VC++) */
  82.  
  83. #define DEFAULT_CONFIG     "blouf.cfg"    /* default config */
  84. #define BLF_DSEPAR         '\\'         /* Directory separator */
  85. #define BLF_BUFSIZE     50000
  86. /* for MSC */                                                                                                              
  87. #include <io.h>
  88.  
  89. #endif /* end sysdep */
  90.  
  91. /* USER CONFIGURATION ENDS HERE */
  92. /* ------------------------------------ Internal Program Definitions */
  93.  
  94. #define    fgets             fblfgets     /* enhanced fgets */
  95. /* temporary macro used to structurize */
  96. #define init_user(a,u,z,n,f,p) a.zone=z; a.net=n; a.node=f; a.point=p; strcpy(a.name,u);
  97.  
  98. #ifndef min
  99. #define min(a,b)         ((a)>(b) ? (b) : (a))
  100. #endif
  101. #ifndef max
  102. #define max(a,b)         ((a)<(b) ? (b) : (a))
  103. #endif
  104. #define    Set(a)            (1 << (a))
  105.  
  106. #ifndef TRUE
  107. #define TRUE            1
  108. #endif
  109. #ifndef FALSE
  110. #define FALSE            0
  111. #endif
  112.  
  113. #define BLF_MAXNPART    10             /* security to prevent infinite msg loop */
  114.  
  115. #define FAIL            1            /* return var for various funcs */
  116. #define SUCCESS            0
  117. #define BOUNCE            1
  118. #define WARNING            2
  119.  
  120. #define NLLEN            30            /* Max NODELIST description len */
  121. #define    NEWSLEN            40            /* max len of a newsgroup name */
  122. #define    FIDOLEN            20            /* max len of a fidonet name */
  123. #define    BLFSTR            150            /* max len of various buffer strings */
  124. #define PASSLEN            10            /* max len of packet password */
  125.  
  126. #define RFCIDKLUDGE     "RFCID:"    /* Implements proposed RFCID kludge */
  127. #define RNEWSSTR         "#! rnews "    /* in news batches...*/
  128. #define DEFAULT_DOMAIN     "fidonet.org"
  129.  
  130. /* ------------------------------------ Structures definitions */
  131.  
  132. typedef struct _bloufgnews{
  133.     char    news[NEWSLEN];
  134.     char    fido[FIDOLEN];
  135.     int write;
  136.     struct _bloufgnews *next;
  137. } GATENEWS;
  138.  
  139. typedef struct
  140. {
  141.     int zone;
  142.     int net;
  143.     int node;
  144.     int point;
  145.     char name[BLFSTR];
  146. } BFIDOUSER;
  147.  
  148. typedef struct _bloufnlist {
  149.     WORD zone;
  150.     WORD net;
  151.     char name[BLFSTR];
  152.     struct _bloufnlist *next;
  153. } LISTIDX;
  154.  
  155. typedef struct _bloufulist {
  156.     char fido[BLFSTR];
  157.     char rfc[BLFSTR];
  158.     struct _bloufulist *next;
  159. } USERIDX;
  160.  
  161. typedef struct {
  162.     int    o_zone;                        /* our 4D fido address */
  163.     int    o_net;
  164.     int    o_node;
  165.     int    o_point;
  166.  
  167.     int    td_net;                        /* our 2d address */
  168.     int    td_node;
  169.  
  170.     int    b_zone;                        /* our boss address */
  171.     int    b_net;
  172.     int    b_node;
  173.  
  174.     int maxsize;                    /* max size for rfc->fido */
  175.     int outmaxsize;                    /* max size fido->internet */
  176.     int fsc0035;                    /* use fsc-0035 kludges */
  177.     int keep;                        /* delete incoming files after import */
  178.     int checkdomain;                /* check primary internet domain */
  179.     int registered;                    /* registered in xxx.fidonet.org namespace */
  180.     int tunnelwarning;                /* bounce mail to your own FTN domain, eg fidonet.org */
  181.     int uucpwarning;                /* warning to .uucp addresses */
  182.     int bitnetwarning;                /* warning to .bitnet addresses */
  183.     int startrek;                    /* add galactic federation approved RFC headers */
  184.     int fourdpkt;                    /* reserved */
  185.     int nopath;
  186.     char pktpass[PASSLEN];            /* packet password */
  187.  
  188.     char outpkt[BLFSTR];            /* path to output fido .pkt */
  189.     char outrfc[BLFSTR];            /* path to output rfc mail */
  190.     char outnws[BLFSTR];            /* (opt) path to output rnews files */
  191.     char dupefile[BLFSTR];            /* (opt) dupefile */
  192.     char tempdir[BLFSTR];            /* temporary directory */
  193.     char uuname[FIDOLEN];            /* name of the uucp site */
  194.     char magic[BLFSTR];                /* name of magic file to request for help */
  195.     char origin[BLFSTR];            /* origin line */
  196.  
  197.     char fgateann[30];                /* filegate, unused at that time */
  198.     char fgateref[BLFSTR];
  199.     char fgatebin[BLFSTR];
  200.     char fgatetemp[BLFSTR];
  201.  
  202.     GATENEWS *firstnews;            /* newsgroup linked list */
  203.     USERIDX *userlist;                /* user list linked list */
  204.     LISTIDX *netlist;                /* net list linked list */
  205. } BCONFIG;
  206.  
  207. /*------------------------------------ Global variables (defined in global.c) */
  208.  
  209. extern BCONFIG *cf;
  210.  
  211. /* ------------------------------------ Prototypes */
  212.  
  213. /* main.c */
  214. void usage(void );
  215. /* fug.c */
  216. int gatemail(BFIDOUSER *, char *, char *, char *,
  217.             struct tm *,char *);
  218. int gatenews(char *, BFIDOUSER *,
  219.                char *, struct tm *, char *, char *, char *);
  220. int process_packet(char *outbound);
  221. /* ufg.c */
  222. int process_rfcfile(char *, FILE *, char *);
  223. int process_news(char *, FILE *);
  224. int process_mailbox(char *, FILE *, char *);
  225. /* misc.c */
  226. char *fblfgets(char *,size_t,FILE *);
  227. FILE *create_rfcfile(char *path,
  228.          char *ext);
  229. void killslash(char *s);
  230. void mksoftcr(char *text);
  231. void clean_string(char *s);
  232. void strip(char *line);
  233. int token(char *tok,
  234.             char *line);
  235. void fputiw(WORD b,
  236.             FILE *a);
  237. WORD fgetiw(FILE *fi);
  238. void fgetf(char *str,
  239.            int max,
  240.            FILE *fi);
  241. int strscan(char a,
  242.               char *line);
  243. int openlog(char *lfname);
  244. void closelog(void);
  245. void logline(const char *line, ...);
  246. /* Prototypes for config.c */
  247. GATENEWS *area_unix2fido(char *name);
  248. GATENEWS *area_fido2unix(char *name);
  249. void cleanconfig(void);
  250. void displayconfig(void );
  251. int openusers(char *);
  252. char *finduser(char *);
  253. int readconfig(char *configfile, char *condition);
  254. int openlist(char *path);
  255. void closelist(void);
  256. char *findnode(int zone, int net, int node);
  257. void setdomain(char *);
  258. char *finddomain(int,int,int);
  259. /* Prototypes for address.c */
  260. void killendspace(char *);
  261. void strdate2tm(char *, struct tm *);
  262. void norm_rfc(char *, char *, char *);
  263. int fido2ints(char *, int *, int *, int *, int *);
  264. int fido2rfc(BFIDOUSER *, char *, char *, char *);
  265. int rfc2fido(BFIDOUSER *, char *);
  266. int bounce_net(int, char *, char *, char *, char *);
  267. void bounce_fido(int, char *,  BFIDOUSER *, char *);
  268. /* prototypes for pkt.c */
  269. unsigned long msgid_serial(void );
  270. FILE *openpacket();
  271. void closepacket(FILE *);
  272. void openpktmessage(FILE *,char *,
  273.     BFIDOUSER *from, BFIDOUSER *to, char *, unsigned long, struct tm *);
  274. void closepktmessage(FILE *);
  275. /* prototypes killdupe.c */
  276. int already_seen(char *);
  277. long dupechk_open(char *);
  278. int dupechk_seen(char *);
  279. void dupechk_close(void);
  280.  
  281. /* eof */
  282.